﻿<div class="padding5left" id="planList" style="height:49%">
    <table id="MyCreatePlanList" fit="true" class="" title="计划列表" pagination="true" url="/PlanManagement/GetMyCreatePlanList"
        fitcolumns="true" singleselect="true">
        <thead>
            <tr>
                <th field="ID" sortable="true" width="180">计划编号</th>
                <th field="JobName" sortable="true" width="140">计划名称</th>
                <th field="JobType" formatter="formatType" sortable="true" width="100">计划类型</th>
                <th field="Invalid" formatter="formatPlanStatus" sortable="true" width="60">状态</th>
                <th field="JobOwnerName" width="60" sortable="true">创建人</th>
                @*<th field="ExpiredTime" sortable="true" formatter="DateFormate" width="100">过期时间</th>*@
            </tr>
        </thead>
    </table>
</div>

<div class="padding5" id="relatedTaskList" style="display: none;height:49%;">
    <table id="MyRelatedTaskList" fit="true" class="" title="计划的任务列表" pagination="true" url="/PlanManagement/GetRelatedTaskList"
        fitcolumns="true" singleselect="true">
        <thead>
            <tr>
                <th field="JobNo" sortable="true" width="100">任务编号</th>
                <th field="Status" formatter="formatStatus" sortable="true" width="60">任务状态</th>
                <th field="OwnerName" sortable="true" width="80">处理人</th>
                <th field="BeginDate" sortable="true" formatter="DateFormate" width="80">触发时间</th>
                <th field="CompleteTime" sortable="true" formatter="DateFormate" width="80">完成时间</th>
                <th field="EndDate" sortable="true" formatter="DateFormate" width="80">过期时间</th>
                <th field="OverFlag" sortable="true" formatter="OverFlagRender">是否过期</th>
            </tr>
        </thead>
    </table>
</div>

<script type="text/javascript">
    $(function () {
        $('#MyCreatePlanList').datagrid({
            pageSize: 10,
            pageList: [10],
            pageNumber: 1,
            onDblClickRow: function (rowIndex, rowData) {

                var url = "/PlanManagement/";
                var type = rowData["JobType"];
                switch (type * 1) {
                    case 1:
                        url += "RoutineInspection";
                        break;
                    case 2:
                        url += "ThirdPartyInspection";
                        break;
                    case 3:
                        url += "GeneralPlan";
                        break;
                }
                url += "?ID=" + rowData["ID"];
                showModuleDialog(url, 1080);
            },
            onLoadSuccess: function (data) {

                $('.datagrid-btable').find('td').each(function () {
                    $(this).attr('title', $(this).text());
                });

                if (data && data["rows"].length) {
                    $('#planList').find('table tr.datagrid-row').first().click();
                }

            },

            //点击计划，在下方显示计划产生的任务列表
            onClickRow: function (rowIndex, rowData) {
                var id = rowData["ID"];
                if (id) {
                    $('#relatedTaskList').show();
                    $('#MyRelatedTaskList').datagrid({
                        pageSize: 10,
                        pageNumber: 1,
                        pageList: [10],
                        queryParams: { planID: id },
                        onLoadSuccess: function (data) {
                            $('.datagrid-btable').find('td').each(function () {
                                $(this).attr('title', $(this).text());
                            });

                            $('#relatedTaskList .panel-title').text('计划' + rowData["ID"] + '的任务列表');
                        },
                        onDblClickRow: function (rowIndex, rowData) {
                            showModuleDialog('/PlanManagement/TaskDetail?UserRole=3&ID=' + rowData["ID"], 1080);
                        }
                    });

                    var p2 = $('#MyRelatedTaskList').datagrid('getPager');
                    $(p2).pagination({
                        beforePageText: '第',
                        afterPageText: '页&nbsp;共&nbsp;{pages}&nbsp;页',
                        displayMsg: '当前显示{from} - {to}&nbsp;条记录&nbsp;共&nbsp;{total}&nbsp;条记录'

                    });
                }
            }
        });

        var p1 = $('#MyCreatePlanList').datagrid('getPager');
        $(p1).pagination({
            beforePageText: '第',
            afterPageText: '页&nbsp;共&nbsp;{pages}&nbsp;页',
            displayMsg: '当前显示{from} - {to}&nbsp;条记录&nbsp;共&nbsp;{total}&nbsp;条记录'

        });


    });
</script>
